/**
 * Copyright © 2024 北京迅安网络系统有限责任公司 Co., Ltd. All rights reserved.
 */

#include "fri_osid_system.h"

void checkAndPrintfError(const char* note, bool okResult)
{
    if (!okResult) {
        printf("############ %s error! ###############\n", note);
    } else {
        printf("%s ok!\n", note);
    }
}

bool checkIdStr(std::string id)
{
    return !id.empty() && id != "error";
}

int main()
{
    printf("cmd_osid_test start!\n");

    // TODO 1. 测试getOSID()
    printf("start to test getOSID\n");
    std::string osid = friGetOSID();
    printf("osid=%s\n", osid.c_str());
    checkAndPrintfError("osid generate", checkIdStr(osid));

    // TODO 2. 测试checkOSID();
    printf("start to checkOSID\n");
    checkAndPrintfError("osid check", friCheckOSID(osid));

    // TODO 3. 测试getPMSID();
    printf("start to checkPMSID\n");
    std::string pmsid = friGetPMSID();
    printf("pmsid=%s\n", pmsid.c_str());
    checkAndPrintfError("pmsid generate", checkIdStr(pmsid));

    // TODO 4. 测试checkPMSID():
    printf("start to checkPMSID\n");
    checkAndPrintfError("pmsid check", friCheckPMSID(pmsid));
    return 0;
}